package com.sq.common.utils.user;

import com.sq.common.constants.Constants;
import com.sq.common.utils.StringUtils;

import java.util.Random;

/**
 * @Author Li sir
 * @Date 2024/9/30
 */
public class PasswordUtil {

    public static final int passlen = 6;

    public static boolean cheek(String pass){
        return true;
    }

    public static boolean cheekPasswordLen(String pass){

        if (StringUtils.isBlank(pass)){
            return false;
        }

        if (pass.length() < passlen){
            return false;
        }
        return true;
    }

    /**
     * 检测密码安全性
     * @param pass
     * @return
     */
    public static boolean cheekPassSafe(String pass){
        return true;
    }

    /**
     * 获取随机盐
     * @param length
     * @return
     */
    public static String getRandomSaft(int length) {
        String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuilder sb = new StringBuilder(length);
        Random random = new Random();

        for (int i = 0; i < length; i++) {
            int index = random.nextInt(characters.length());
            sb.append(characters.charAt(index));
        }

        return sb.toString();
    }


}
